package com.lbm.exercise;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.MockedStatic;
import org.mockito.junit.MockitoJUnitRunner;

import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mockStatic;

@RunWith(MockitoJUnitRunner.class)
public class CalculationTest {

    @InjectMocks
    Calculation calculation;


    @Test
    public void test1(){
        MockedStatic<Division> div = mockStatic(Division.class);
        div.when(()->{
            com.lbm.exercise.Division.divide(anyInt(),anyInt());
        }).thenThrow(new Exception());

        boolean isError = false;
        try{
            calculation.compute(1,2);
        }catch (Exception e){
            isError = true;
            System.out.println("你好");
        }finally {
            assertTrue(isError);
        }

    }


}
